<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="js/jquery.min.js" type="text/javascript"></script>
<link href="css/zhu/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<link href="css/zhu/memberrole.css" rel="stylesheet">
<link href="css/zhu/Administrators.css" rel="stylesheet">
<script type="text/javascript">
	$(function() {
		$("#tijiaorole").click(function() {
			//获得角色名称
			var namerole = $("input[name=namerole]").val();
			if (namerole == null || namerole == "") {
				$(".role_tips > span").html("角色名称不能为空！");
				$("input[name=namerole]").focus();
				return;
			} else {
				$(".role_form").submit();
			}
		})
		//删除
		$("[roleshanchu]").click(function() {
			//获得ID
			var zhehang = $(this);
			var roleid = $(this).attr("roleshanchu");
			$.get("deleteRoleid", {
				roleid : roleid
			}, function(data, success) {
				if (data == "删除成功") {
					alert("删除成功！");
					console.log($(this).parent().parent());
					zhehang.parent().parent().remove();
				}
			}, "text");
		})
		$("[tijiao_role]").click(function () {
			var tr = $(this).parent().prev().find("tr");
			var role_name = tr.eq(0).find("input").val();
			var role_id=tr.eq(1).find("input").val();
			$.post("modifyrole", {
				role_name : role_name,
				role_id :role_id
			}, function(data, success) {
				alert(data);
				location.href = "/fuhe/zhu";
			})
		})
	});
</script>
</head>
<body>
	<!--
        	作者：offline
        	时间：2017-10-30
        	描述：角色管理
        -->
	<c:set var="isDoing" value="0" />
	<c:forEach items="${powerList}" var="power" varStatus="status">

		<c:if test="${power.name=='角色管理' && isDoing==0}" var="u">
			<!--  设置跳出 条件 -->
			<c:set var="isDoing" value="1" />
			<div class="zuidadiv">
				<div class="zuishangdiv">角色管理</div>
				<div class="zhongjiandiv">
					<ul>
						<li>
							<button type="button" class="btn btn-primary" data-toggle="modal"
								data-target="#myModal10">添加</button>
							<div class="modal fade" id="myModal10" tabindex="-1"
								role="dialog" aria-labelledby="myModalLabel">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button data-dismiss="modal" class="close" type="button">
												<span aria-hidden="true">×</span><span class="sr-only">Close</span>
											</button>
											<h4 class="modal-title">添加</h4>
										</div>
										<div class="modal-body">
											<form action="/fuhe/addrole" style="padding-left: 85px"
												class="role_form" method="post">
												<input type="hidden" value="" />
												<table>
													<tbody>
														<tr>
															<td>角色名称:</td>
															<td><input name="namerole" type="text">
																<div class="role_tips">
																	<span style="color: red"></span>
																</div></td>
														</tr>
													</tbody>
												</table>
											</form>
										</div>
										<div class="modal-footer">
											<button data-dismiss="modal" class="btn btn-default"
												type="button">关闭</button>
											<button class="btn btn-primary" type="button" id="tijiaorole">提交</button>
										</div>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal-dialog -->
							</div>
						</li>
					</ul>
				</div>
				<div>
					<table width="100%" border="0" cellspacing="0" cellpadding="0"
						class="tablelist table table-striped table-bordered table-hover  table-condensed">
						<thead>
							<th width="70%">角色名称</th>
							<th width="30%">操作</th>
						</thead>
						<tbody>
							<c:forEach items="${rol}" var="ro">
								<tr>
									<td>${ro.name}</td>
									<td><button type="button" class="btn btn-primary"
											data-toggle="modal" data-target="#myModal9">修改</button>
											<button type="button" class="btn btn-primary"
											data-toggle="modal" data-target="#quanxianfenpei">权限分配</button>
										<button type="button" class="btn btn-primary"
											data-toggle="modal" data-target="#myModal8"
											roleshanchu="${ro.id}">删除</button></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</c:if>
		<c:if test="${fn:length(powerList) == status.count && isDoing==0 }">
			<c:if test="${!u }">
				<jsp:include page="403.jsp"></jsp:include>
			</c:if>
		</c:if>
	</c:forEach>
</body>
</html>